const app = getApp()
import{convertToCastString} from '../../utils/util'
Page({

	/**
	 * 页面的初始数据
	 */
	data: {

	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		wx.request({
			url: app.gBaseUrl + 'subject/' + options.mid,
			success: (res) =>{
				console.log(res.data)
				this.processMovieData(res.data)
			}
		})
		
	},
	onViewPost () {
		wx.previewImage({
			urls: [this.data.movie.image],
		})
	},
	processMovieData(movie){
		const data = {}
		data.directors = convertToCastString(movie.directors)
		data.casts = movie.casts
		data.castsName = convertToCastString(movie.casts)
		data.image = movie.images.large
		data.title = movie.title
		data.subtitle = movie.countries[0]+'.'+ movie.year
		data.wishCount = movie.wish_count
		data.commentsCount = movie.comments_count
		data.originalTitle = movie.original_title
		data.rating = movie.rating
		data.generes = movie.genres.join('/')
		data.summary = movie.summary
		this.setData({
			movie:data
		})
	},
	onReady () {
		const query = wx.createSelectorQuery()
		query.select('#scroll').boundingClientRect().exec((res) =>{
			console.log(res)
		})
		
	}
})